package com.itheima.d1_properties;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

/*
    目标：掌握把键值对数据存入到属性文件中去
        public void store(OutputStream os, String comments)	把键值对数据，通过字节输出流写出到属性文件里去
        public void store(Writer w, String comments)	把键值对数据，通过字符输出流写出到属性文件里去
        public void load(InputStream is)	通过字节输入流，读取属性文件里的键值对数据
        public void load(Reader reader)	通过字符输入流，读取属性文件里的键值对数据
 */
public class PropertiesTest2 {
    public static void main(String[] args) throws Exception {
        Properties prop = new Properties();
        prop.setProperty("小明", "18");
        prop.setProperty("小红", "20");
        prop.setProperty("小兰", "21");

        System.out.println(prop);

        prop.store(new FileWriter("aaa1.properties"), "名单");

        Properties prop2 = new Properties();
        prop2.load(new FileReader("aaa.properties"));
        System.out.println(prop2);
    }
}
